<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {
    public function index(){
        $this->display();
    }
    public function dologin(){
        if($_POST['name']==null or $_POST['password']==null){
            $this->error('账号和密码不能为空！');
        }
        $where=array(
            'name'=>$_POST['name'],
        );
        $user=M('Gl')->where($where)->find();
        if($user['password']!=md5($_POST['password'])){
            $this->error('密码错误！');
        }elseif($user['qx']!=1){
            $this->error('你没有权限操作！');
        }else{
            $cookic=cookie('name',$_POST['name'],3600);
            $cookic=cookie('uid',$user['id'],3600);
            $this->success('登陆成功',U('Admin/index'));
        }

    }
}